
//
//  HotViewController.m
//  YKZB
//
//  Created by 曾少伟 on 2017/3/16.
//  Copyright © 2017年 曾少伟. All rights reserved.
//

#import "HotViewController.h"
#import "ShowViewModel.h"
#import "HotCell.h"

@interface HotViewController ()
@property (nonatomic,strong)NSMutableArray *arrData;

@end

@implementation HotViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createSubviews];
    [self loadData];
}



#pragma mark - data
- (void)loadData {
    [ShowViewModel getHotVCData:^(id json) {
//        NSLog(@"%@",json);
        [self.arrData addObjectsFromArray:json];
        [self.tableView reloadData];
    } failed:^(id json) {
        NSLog(@"%@",json);
    }];
}

#pragma mark - get set
- (NSMutableArray *)arrData {
    if (!_arrData) _arrData = [NSMutableArray new];
    return _arrData;
}

#pragma mark -tableview delegate datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.arrData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    HotCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    [cell setCell:self.arrData[indexPath.row]];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return ScreenW + 70 + 10;
}

#pragma mark - view 
- (void)createSubviews {
    self.automaticallyAdjustsScrollViewInsets = YES;
//    self.edgesForExtendedLayout = UIRectEdgeBottom;
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    UINib *nib = [UINib nibWithNibName:[HotCell className] bundle:nil];
    [self.tableView registerNib:nib forCellReuseIdentifier:@"Cell"];
}
@end
